describe("App.api_accounts in India", function() {
	var api, response;

	beforeEach(function() {
		response = {
			productListResponse: {
                loanList: [{
                    "currentBalance": 1887.72
                }],
                cardList: [{
                    "currentBalance": 1887.72
                }],
                responseHeader: {
                    status: 1,
                    currentTimestamp: "2011-10-01T13:58:33.104+0530",
                    nonce: "2175d8662534e58e9c77ca35def779f7"
                }
            }
		};

		api = App.api_accounts;
	});

	describe("_buildAccountList", function() {
		it("accountType is loan", function() {

			var accountListObj = api._buildAccountList(response.productListResponse.loanList, 'loan');

			expect(accountListObj.totalBalance).toEqual('1887.72');	
			expect(accountListObj.list[0] instanceof App.LoanAccount).toBeTruthy();
		});

		it("accountType is card", function() {
			var accountListObj = api._buildAccountList(response.productListResponse.cardList, 'card');

            expect(accountListObj.totalBalance).toEqual('1887.72');
            expect(accountListObj.list[0] instanceof App.CardAccount).toBeTruthy();
		});

		it("accountType is product", function() {
			var productList = [{
                localCurrentBalance: 100.12,
                productCode: "DDA",
                subProductCode: "100",
                productGroup: "STMT"
            }];
			var t_account = App.CurrentSavingsAccount.create(productList[0]);

            spyOn(api, '_buildAccount').andReturn(t_account);

            var accountListObj = api._buildAccountList(productList, 'product');

			expect(accountListObj.totalBalance).toEqual('100.12');
            expect(api._buildAccount).toHaveBeenCalledWith(productList[0]);            
		});
	});

});